package com.longge;

import java.util.ArrayList;
import java.util.List;



/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-04-11 23:40
 */
public class ReversePrint {

    List<Integer> res = new ArrayList<>();

    public int[] reversePrint(ListNode head) {
        reverse(head);
        return res.stream().mapToInt(c -> c).toArray();
    }

    private void reverse(ListNode head) {
        if (head==null) return;
        reverse(head.next);
        res.add(head.val);
    }
}
